﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WMSSoft.Lib.Basic;
using WMSSoft.Lib.WinKStart;
using WMSSoft.Lib.Texte;
using WMSSoft.Lib.WinKStart.Abstract;
using WMSSoft.Lib.WinKStart.Model;

using WMSSoft.Lib.WinKStart.ViewModel;

namespace WMSSoft.WinKStart.ViewModel
{
    public class CWinKStartContextMenuViewModel : CViewModelBase
    {
        List<CContextDataItem> _WinKStartContextMenuItems = null;
        ContextMenuSettings _Data = null;

        public CWinKStartContextMenuViewModel()
        {
            ReadContextMenuItems();
        }

        public CWinKStartContextMenuViewModel(ContextMenuSettings Settings)
        {
            //base.ViewName = ViewCaption;
            _Data = Settings;
            ReadContextMenuItems();
        }

        public List<CContextDataItem> ContextMenuItems
        {
            get { return _WinKStartContextMenuItems; }
            set
            {
                _WinKStartContextMenuItems = value;
                OnPropertyChanged("ContextMenuItems");
            }
        }

        public ContextMenuSettings Data
        {
            get { return _Data; }
        }
        public ContextMenuSettings ApplyChangedData()
        {
            ContextMenuSettings tmpData = new ContextMenuSettings();

            tmpData.Taskmanager = ContextMenuItems[0].Value;
            tmpData.Systemcontrol = ContextMenuItems[1].Value;
            tmpData.Explorer = ContextMenuItems[2].Value;
            tmpData.Run = ContextMenuItems[3].Value;
            tmpData.Search = ContextMenuItems[4].Value;
            tmpData.ProgramsAndFeatures = ContextMenuItems[5].Value;
            tmpData.MobiltyCenter = ContextMenuItems[6].Value;
            tmpData.PowerOptions = ContextMenuItems[7].Value;
            tmpData.EventViewer = ContextMenuItems[8].Value;
            tmpData.System = ContextMenuItems[9].Value;
            tmpData.DeviceManager = ContextMenuItems[10].Value;
            tmpData.NetworkConnections = ContextMenuItems[11].Value;
            tmpData.Diskmanagement = ContextMenuItems[12].Value;
            tmpData.Computermanagement = ContextMenuItems[13].Value;
            tmpData.CmdShell = ContextMenuItems[14].Value;
            tmpData.CmdShellAdministrator = ContextMenuItems[15].Value;
            tmpData.PowerShell = ContextMenuItems[16].Value;
            tmpData.PowerShellAdministrator = ContextMenuItems[17].Value;
            tmpData.WinKStartSettings = ContextMenuItems[18].Value;
            tmpData.WinKStartExit = ContextMenuItems[19].Value;
            tmpData.WindowsSessionCtl = ContextMenuItems[20].Value;

            return tmpData;
        }

        void ReadContextMenuItems()
        {
            try
            {
                ContextMenuItems = new List<CContextDataItem>();

                ContextMenuItems.Add(new CContextDataItem("mni_SB_Taskmanagere", LanguageStrings.GetText("Task-manager"), _Data.Taskmanager));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_SysstemControl", LanguageStrings.GetText("System-control"), _Data.Systemcontrol));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_Explorer", LanguageStrings.GetText("Windows Explorer"), _Data.Explorer));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_Run", LanguageStrings.GetText("Run"),_Data.Run));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_Search", LanguageStrings.GetText("Search"), _Data.Search));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_ProgramsFeatures", LanguageStrings.GetText("Programs and Features"), _Data.ProgramsAndFeatures));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_MobilityCenter", LanguageStrings.GetText("Mobility Center"),_Data.MobiltyCenter));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_PowerOptions", LanguageStrings.GetText("Power Options"),_Data.PowerOptions));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_EventViewer", LanguageStrings.GetText("EventViewer"),_Data.EventViewer));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_System", LanguageStrings.GetText("System"),_Data.System));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_DeviceManager", LanguageStrings.GetText("Device Manager"),_Data.DeviceManager));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_NetworkConnections", LanguageStrings.GetText("Network Connections"),_Data.NetworkConnections));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_Diskmanagement", LanguageStrings.GetText("Disk-management"),_Data.Diskmanagement));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_Computermanagement", LanguageStrings.GetText("Computer-management"),_Data.Computermanagement));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_Cmd", LanguageStrings.GetText("Command Shell"),_Data.CmdShell));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_CmdAdmin", LanguageStrings.GetText("Command Shell(Administrator)"),_Data.CmdShellAdministrator));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_PwS", LanguageStrings.GetText("Powershell"),_Data.PowerShell));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_PwSAdmin", LanguageStrings.GetText("Powershell(Administrator)"),_Data.PowerShellAdministrator));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_WinKStartSettings", LanguageStrings.GetText("WinKStart Settings"),_Data.WinKStartSettings));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_WinKStartExit", LanguageStrings.GetText("WinKStart Exit"),_Data.WinKStartExit));
                ContextMenuItems.Add(new CContextDataItem("mni_SB_WindowsSessionCtl", LanguageStrings.GetText("Shutdown"), _Data.WindowsSessionCtl));

                OnPropertyChanged("ContextMenuItems");
            }
            catch (Exception Ex)
            {
                CMessagelogging.AppendMessage(ErrorMessages.USERSETTINGS__ERROR_UNABLE_TO_READ_CONTEXTMENUITEMS_CONFIG, Ex, true, EMessageTypes.Error);
            }
        }
    }
}
